home *** CD-ROM | disk | FTP | other *** search
/ Amiga Format CD 38 / Amiga Format CD38 (1999-03-15)(Future Publishing)(GB)(Track 1 of 3)[!][issue 1999-04].iso / -seriously_amiga- / misc / football / user / cup_viewteamprogress.rexx < prev    next >
OS/2 REXX Batch file  |  1999-02-03  |  13KB  |  350 lines

  1. /* ***********************************************************************
  2.  
  3.    VIEW TEAM PROGRESS PROGRAM FOR FOOTBALL REXX SUITE
  4.   ----------------------------------------------------
  5.                    Copyright  Mark Naughton 1997
  6.  
  7.  
  8. Version    Date     History
  9. --------------------------------------------------------------------------
  10.  1.0       181297   First release.
  11.            140998   Added support for Two-Leg matches and Away Goals.
  12.  
  13. **************************************************************************
  14.  
  15. Procedure
  16. ---------
  17.  
  18. 1. Check files exist.
  19. 2. Read '.cf' file and get cup name and team list.
  20. 3. Search for selected team and give error if cannot find it, else set
  21.    marker.
  22. 4. Read '.scf' file and read in all round names and matches that the
  23.    selected team was in.
  24. 5. Display title.
  25. 6. Loop. Get roundname and change if replay. Get Home and Away type.
  26. 7. Read match and get opponent and score, adding it to goals conceeded
  27.    and goals scored.
  28. 8. Check next line for Extra Time, and append to score string. Change
  29.    goals_con/scored accordingly.
  30. 9. Check next line for Penalties, and append to score string.
  31. 10.Display round, home/away, opponent and score.
  32. 11.End loop.
  33. 12.Exit.
  34.  
  35. ************************************************************************** */
  36. PARSE ARG league_stuff
  37.  
  38. version      = 1
  39. input_file   = '.cf'
  40. input2_file  = '.scf'
  41. separator    = '*'
  42. matches.     = '???'
  43. mcount       = 0
  44. not_played   = '__   __'
  45. teams.       = '???'
  46. counter      = 0
  47. title        = '*CUP_TITLE='
  48. awaygs       = '*CUP_AWAYG='
  49.  
  50.  
  51. parse var league_stuff league_file search_team
  52. league_file = "Data/" || league_file
  53.  
  54. if exists(league_file || input_file) = 0  then exit
  55. if exists(league_file || input2_file) = 0 then exit
  56.  
  57. if open(datafile,league_file || input_file,'r') then do
  58.    do while ~eof(datafile)
  59.       line = readln(datafile)
  60.       if pos(title,line) > 0 then        cupname= delstr(line,1,11)
  61.       if pos(awaygs,line) > 0 then       awayg  = delstr(line,1,11)
  62.       if pos(separator,line) = 0 then do
  63.          line = strip(line)
  64.          if counter = 0 then do
  65.             teams.1 = line
  66.             counter = 1
  67.          end
  68.          else do
  69.             counter       = counter + 1
  70.             teams.counter = line
  71.          end
  72.       end
  73.    end
  74.    close(datafile)
  75. end
  76. else do
  77.    say
  78.    say "ERROR :    (ViewTeamProgress)"
  79.    say
  80.    say "Cannot open '"league_file||input_file"' for reading."
  81.    exit
  82. end
  83.  
  84. sel=-1
  85. search_team = strip(search_team)
  86. do i=1 to counter
  87.    if pos(search_team,teams.i) > 0 then
  88.       sel = i
  89. end
  90. if sel < 0 then do
  91.    say
  92.    say "ERROR :    (ViewTeamProgress)"
  93.    say
  94.    say "Incorrect team. '"search_team"' cannot be found in this"
  95.    say "cup."
  96.    exit
  97. end
  98.  
  99. if open(datafile,league_file || input2_file,'r') then do
  100.    do while ~eof(datafile)
  101.       line = readln(datafile)
  102.       if pos("*Round",line) > 0 then do
  103.          mcount = mcount + 1
  104.          matches.mcount = line
  105.       end
  106.       if pos(separator,line) = 0 & pos("#",line) = 0 then do
  107.          line = strip(line)
  108.          if pos(teams.sel,line) > 0 then do
  109.             mcount = mcount + 1
  110.             matches.mcount = line
  111.             mkr = 1
  112.          end
  113.          else
  114.             mkr = 0
  115.       end
  116.       if pos("#",line) > 0 & mkr = 1 then do
  117.          mcount = mcount + 1
  118.          matches.mcount = line
  119.       end
  120.    end
  121.    close(datafile)
  122. end
  123. else do
  124.    say
  125.    say "ERROR :    (ViewTeamProgress)"
  126.    say
  127.    say "Cannot open '"league_file||input2_file"' for reading."
  128.    exit
  129. end
  130.  
  131. say
  132. say center("'"cupname"'",78)
  133. say "-------------------------------------------------------------------------------"
  134. say
  135. say "Team : "teams.sel
  136. say
  137. say
  138. say "Round          Where?  Match        (The selected team's score is always first)"
  139. say "-------------------------------------------------------------------------------"
  140. say
  141. goals_con = 0
  142. goals_scr = 0
  143. donem = 0
  144.  
  145. do i=1 to mcount
  146.    if pos("*Round",matches.i) > 0 then do
  147.       if pos("Replay",matches.i) > 0 then
  148.          round = left("Replay",15,' ')
  149.       else do
  150.          parse var matches.i "*Round="name
  151.          round = substr(name,1,5)
  152.          if pos("1 Leg",name) > 0 then round = round||" (1st L)"
  153.          if pos("2 Legs",name) > 0 then round = round||" (2nd L)"
  154.          round = left(round,15,' ')
  155.       end
  156.       donem = 0
  157.       h = 0
  158.       j = i + 1
  159.       if pos(teams.sel,matches.j) = 1 then do
  160.          round = round||"Home    "
  161.          h = 1
  162.          donem = 1
  163.       end
  164.       if pos(teams.sel,matches.j) > 1 then do
  165.          round = round||"Away    "
  166.          h = 2
  167.          donem = 1
  168.       end
  169.       if donem = 1 then do
  170.          if pos(not_played,matches.j) > 0 then do
  171.             if h = 1 then opponent = strip(substr(matches.j,41,30))
  172.             if h = 2 then opponent = strip(substr(matches.j,1,30))
  173.             say round""left(opponent,32)"     -  To Be Played."
  174.          end
  175.          else do
  176.             sd = ''
  177.             if pos("2 Legs",name) > 0 then do
  178.                for = strip(substr(matches.j,32,2))
  179.                aga = strip(substr(matches.j,37,2))
  180.                if h = 1 then do
  181.                   sd = right(for,2)"-"left(aga,2)
  182.                   goals_scr = goals_scr + for
  183.                   goals_con = goals_con + aga
  184.                   opponent = strip(substr(matches.j,41,30))
  185.                end
  186.                else do
  187.                   sd = right(aga,2)"-"left(for,2)
  188.                   goals_scr = goals_scr + aga
  189.                   goals_con = goals_con + for
  190.                   opponent = strip(substr(matches.j,1,30))
  191.                end
  192.                k = j + 1
  193.                if pos("#1st Leg",matches.k) > 0 then do
  194.                   parse var matches.k "#1st Leg" for1l aga1l .
  195.                   for1l = strip(for1l)
  196.                   aga1l = strip(aga1l)
  197.                   if h = 1 then
  198.                      sd = sd"  Agg: "right(for1l+for,2)"-"left(aga1l+aga,2)
  199.                   else
  200.                      sd = sd"  Agg: "right(aga1l+aga,2)"-"left(for1l+for,2)
  201.                   if (for1l+for) = (aga + aga1l) then do
  202.                      if pos("YES",awayg) > 0 then do
  203.                         if for1l > aga then do
  204.                            if h = 1 then
  205.                               extra_line = "                                                                 "strip(teams.sel)" win on Away goals."
  206.                            else
  207.                               extra_line = "                                                                 "opponent" win on Away goals."
  208.                            np = 1
  209.                         end
  210.                         if for1l < aga then do
  211.                            if h = 1 then
  212.                               extra_line = "                                                                 "opponent" win on Away goals."
  213.                            else
  214.                               extra_line = "                                                                 "strip(teams.sel)" win on Away goals."
  215.                            np = 1
  216.                         end
  217.                      end
  218.                   end
  219.                end
  220.                k = k + 1
  221.                if pos("#Score After Extra Time",matches.k) > 0 then do
  222.                   for1 = strip(substr(matches.k,32,2))
  223.                   aga1 = strip(substr(matches.k,37,2))
  224.                   if h = 1 then do
  225.                      sd = sd".  AET: "right(for1,2)"-"left(aga1,2)"   Agg: "right(for1l+for1,2)"-"left(aga1l+aga1,2)
  226.                      goals_scr = goals_scr - for + for1
  227.                      goals_con = goals_con - aga + aga1
  228.                   end
  229.                   else do
  230.                      sd = sd".  AET: "right(aga1,2)"-"left(for1,2)"   Agg: "right(aga1l+aga1,2)"-"left(for1l+for1,2)
  231.                      goals_scr = goals_scr - aga + aga1
  232.                      goals_con = goals_con - for + for1
  233.                   end
  234.                   if (for1+for1l) = (aga1 + aga1l) then do
  235.                      if pos("YES",awayg) > 0 then do
  236.                         if for1 > aga then do
  237.                            if h = 1 then
  238.                               extra_line = "                                                                 "strip(teams.sel)" win on Away goals,"
  239.                            else
  240.                               extra_line = "                                                                 "opponent" win on Away goals,"
  241.                            extra_line2= "                                                                 "after Extra Time."
  242.                            np = 2
  243.                         end
  244.                         if for1 < aga then do
  245.                            if h = 1 then
  246.                               extra_line = "                                                                 "opponent" win on Away goals,"
  247.                            else
  248.                               extra_line = "                                                                 "strip(teams.sel)" win on Away goals,"
  249.                            extra_line2= "                                                                 "after Extra Time."
  250.                            np = 2
  251.                         end
  252.                      end
  253.                   end
  254.                   k = k + 1
  255.                   if pos("#Penalties",matches.k) > 0 then do
  256.                      for1 = strip(substr(matches.k,32,2))
  257.                      aga1 = strip(substr(matches.k,37,2))
  258.                      sd = sd||","
  259.                      if h = 1 then
  260.                         extra_line3 = "                                                                 After Penalties: "right(for1,2)"-"left(aga1,2)
  261.                      else
  262.                         extra_line3 = "                                                                 After Penalties: "right(aga1,2)"-"left(for1,2)
  263.                      np = 3
  264.                   end
  265.                end
  266.                else do
  267.                   if pos("#Penalties",matches.k) > 0 then do
  268.                      for1 = strip(substr(matches.k,32,2))
  269.                      aga1 = strip(substr(matches.k,37,2))
  270.                      if h = 1 then
  271.                         sd = sd"  After Penalties: "right(for1,2)"-"left(aga1,2)
  272.                      else
  273.                         sd = sd"  After Penalties: "right(aga1,2)"-"left(for1,2)
  274.                   end
  275.                end
  276.             end
  277.             if pos("2 Legs",name) = 0 then do
  278.                for = strip(substr(matches.j,32,2))
  279.                aga = strip(substr(matches.j,37,2))
  280.                if h = 1 then do
  281.                   sd = right(for,2)"-"left(aga,2)
  282.                   goals_scr = goals_scr + for
  283.                   goals_con = goals_con + aga
  284.                   opponent = strip(substr(matches.j,41,30))
  285.                end
  286.                else do
  287.                   sd = right(aga,2)"-"left(for,2)
  288.                   goals_scr = goals_scr + aga
  289.                   goals_con = goals_con + for
  290.                   opponent = strip(substr(matches.j,1,30))
  291.                end
  292.                g = j + 1
  293.                if pos("#Score After Extra Time",matches.g) > 0 then do
  294.                   for1 = strip(substr(matches.g,32,2))
  295.                   aga1 = strip(substr(matches.g,37,2))
  296.                   if h = 1 then do
  297.                      sd = sd"  AET: "right(for1,2)"-"left(aga1,2)
  298.                      goals_scr = goals_scr - for + for1
  299.                      goals_con = goals_con - aga + aga1
  300.                   end
  301.                   else do
  302.                      sd = sd"  AET: "right(aga1,2)"-"left(for1,2)
  303.                      goals_scr = goals_scr - aga + aga1
  304.                      goals_con = goals_con - for + for1
  305.                   end
  306.                   g = g + 1
  307.                   if pos("#Penalties",matches.g) > 0 then do
  308.                      for1 = strip(substr(matches.g,32,2))
  309.                      aga1 = strip(substr(matches.g,37,2))
  310.                      if h = 1 then
  311.                         sd = sd"  After Penalties: "right(for1,2)"-"left(aga1,2)
  312.                      else
  313.                         sd = sd"  After Penalties: "right(aga1,2)"-"left(for1,2)
  314.                   end
  315.                end
  316.                else do
  317.                   if pos("#Penalties",matches.g) > 0 then do
  318.                      for1 = strip(substr(matches.g,32,2))
  319.                      aga1 = strip(substr(matches.g,37,2))
  320.                      if h = 1 then
  321.                         sd = sd"  After Penalties: "right(for1,2)"-"left(aga1,2)
  322.                      else
  323.                         sd = sd"  After Penalties: "right(aga1,2)"-"left(for1,2)
  324.                   end
  325.                end
  326.             end
  327.             say round""left(opponent,32)"   "sd
  328.             if np > 0 then do
  329.                if np = 3 then say extra_line3
  330.                if np = 1 | np = 2 then say extra_line
  331.                if np = 2 then say extra_line2
  332.                np = 0
  333.             end
  334.             donem = 0
  335.          end
  336.       end
  337.    end
  338. end
  339. say
  340. say
  341. say
  342. say "Goals Scored    : "goals_scr
  343. say "Goals Conceeded : "goals_con
  344. say
  345. say
  346. say "-------------------------------------------------------------------------------"
  347.  
  348. exit
  349.  
  350. /*************************************************************************************/